package com.ruoyi.project.system.activity.service.impl;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.common.utils.uniquekey.IdGererateFactory;
import com.ruoyi.project.system.activity.domain.Activity;
import com.ruoyi.project.system.activity.mapper.ActivityMapper;
import com.ruoyi.project.system.activity.service.IActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 案例区Service接口
 *
 * @author lcl
 * @date 2020-11-18
 */
@Service
public class ActivityServiceImpl implements IActivityService 
{
    @Resource
    private IdGererateFactory idGererateFactory;
    @Autowired
    private ActivityMapper activityMapper;

    /**
     * 查询案例
     * 
     * @param id 案例ID
     * @return 案例
     */
    @Override
    public Activity selectActivityById(String id)
    {
        return activityMapper.selectActivityById(id);
    }

    /**
     * 查询案例列表
     * 
     * @param activity 案例
     * @return 案例
     */
    @Override
    public List<Activity> selectActivityList(Activity activity)
    {
        return activityMapper.selectActivityList(activity);
    }

    /**
     * 新增案例
     * 
     * @param activity 案例
     * @return 结果
     */
    @Override
    public int insertActivity(Activity activity)
    {
        activity.setId(this.idGererateFactory.nextStringId());
        return activityMapper.insertActivity(activity);
    }

    /**
     * 修改案例
     * 
     * @param activity 案例
     * @return 结果
     */
    @Override
    public int updateActivity(Activity activity)
    {
        return activityMapper.updateActivity(activity);
    }

    /**
     * 删除案例对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteActivityByIds(String ids)
    {
        return activityMapper.deleteActivityByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除案例信息
     * 
     * @param id 案例ID
     * @return 结果
     */
    @Override
    public int deleteActivityById(String id)
    {
        return activityMapper.deleteActivityById(id);
    }

    @Override
    public List<Activity> findList() {
        return this.activityMapper.findList();
    }
}
